<template>
  <div>
    <!-- 头部面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 中心卡片区域 -->
    <el-card class="box-card">
      <el-table :data="permissionData" border v-loading="loading">
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column v-slot="slot" label="权限等级">
          <el-tag v-if="slot.row.level === '0' ">一级</el-tag>
          <el-tag v-else-if="slot.row.level === '1' " type="success">二级</el-tag>
          <el-tag v-else type="warning">三级</el-tag>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { reqPermissionList } from "../../api/index";
export default {
  data() {
    return {
      loading: false,
      permissionData: []
    };
  },
  methods: {
    // 获取权限列表数据
    async getPermissionList() {
      this.loading = true;
      const result = await reqPermissionList();
      if (result.meta.status === 200) {
        this.permissionData = result.data;
      } else {
        this.$message.error(result.meta.msg);
      }
      this.loading = false;
    }
  },

  created() {
    this.getPermissionList();
  }
};
</script>

<style lang="less" scoped>
.el-card {
  margin-top: 20px;
  width: 100%;
  height: 100%;

  .el-table {
    width: 98%;
    height: 100%;
    margin-top: 20px;
  }
}
</style>